﻿using Microsoft.Office.Server.Search.Query;

namespace Trentacular.Office.Server.Search.FacetedSearch.Providers
{
    /// <summary>
    /// The common interface for a facet provider.
    /// </summary>
    public interface IFacetProvider
    {
        /// <summary>
        /// Gets or sets the faceted search context.
        /// </summary>
        /// <value>The faceted search context.</value>
        FacetedSearchContext FacetedSearchContext { get; set; }

        /// <summary>
        /// Gets or sets the configuration.
        /// </summary>
        /// <value>The configuration.</value>
        FacetProviderConfiguration Configuration { get; set; }

        /// <summary>
        /// Gets the managed properties that need to be included in the facet query.
        /// </summary>
        /// <value>The managed properties to be included in the facet query.</value>
        string[] ManagedPropertiesToQuery { get; }

        /// <summary>
        /// Initializes the facet provider before any rows have been iterated.
        /// </summary>
        /// <param name="resultTable">The result table.</param>
        void Initialize(ResultTable resultTable);

        /// <summary>
        /// Processes a single row of the result table.
        /// </summary>
        /// <param name="resultTable">The result table.</param>
        void ProcessRow(ResultTable resultTable);

        /// <summary>
        /// Called after all rows have been processed and returns the generated facets.
        /// </summary>
        /// <returns>A FacetGroup containing the list of generated facets</returns>
        FacetGroup GetFacets();
    }
}
